<?php 
	$cdnUrl = Zend_Registry::get('cdnServer');
	$baseUrl = Zend_Registry::get('baseServer');
?>
<style type="text/css">
#ajaxLoader{
	display:none;
	margin: auto;
	z-index: 999;
}
</style>

<link href="<?php echo $cdnUrl?>/plugins/uni-form/css/uni-form.css" rel="stylesheet" media="screen" type="text/css" />
<link href="<?php echo $cdnUrl?>/plugins/uni-form/css/default.uni-form.css" rel="stylesheet" media="screen" type="text/css" />
<link href="<?php echo $cdnUrl?>/css/app.uni-form.css" rel="stylesheet" media="screen" type="text/css" />

<h1 class="page_title">Job Seeker Registration</h1>
<div id="jobSeekerRgrnForm" style="padding:0 10px 10px 10px; border:1px solid black">
	<form action="javascript:submit();" autocomplete="false" class="uniForm">
	
		<fieldset id="loginInfo" >
	        <h3>Login Information</h3>
	        
	        <div class="ctrlHolder">
	          <label for="username"><em class="red">*</em>Username</label>
	          <input name="username" id="username" size="35" maxlength="15" type="text" class="required validatePhrase"/>
	          <p class="formHint usernamehint">Max length 15 characters.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="password"><em class="red">*</em>Password</label>
	          <input name="password" id="password" size="35" maxlength="15" type="password" class="required validatePhrase"/>
	          <p class="formHint">Max length 15 characters</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="email"><em class="red">*</em>Primary Email</label>
	          <input name="email" id="email" size="35" maxlength="50" type="text" class="required validateEmail"/>
	          <p class="formHint">Email address to be used by recruiters.</p>
	        </div>
	        
        </fieldset>
        
        <fieldset id="basicInfo" >
	        <h3>Basic Information</h3>
	        <div class="ctrlHolder">
	          <label for="name"><em class="red">*</em>Name</label>
	          <input name="name" id="name" size="35" maxlength="80" type="text" class="required"/>
	          <p class="formHint">Your name as per your resume.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="curr_location">Current Location</label>
	          <input name="curr_location" id="curr_location" size="35" maxlength="50" type="text"/>
	          <p class="formHint">Current location or city in which currently located.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="mobile_no">Mobile Number</label>
	          <input name="mobile_no" id="mobile_no" size="35" maxlength="10" type="text" class="validateNumber"/>
	          <p class="formHint">Personal mobile number. Donot use 0 or +91.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="alternate_no">Alternate Number</label>
	          <input name="alternate_no" id="alternate_no" size="35" maxlength="30" type="text" class="validateNumber"/>
	          <p class="formHint">Alternate mobile number or landline number. Donot use 0 or +91. e.g. 0112345678 </p>
	        </div>
        
        </fieldset>
        
        <fieldset id="corpPro" >
	        <h3>Corporate Profile</h3>
	        <div class="ctrlHolder">
	          <label for="">Experince</label>
	          <input name="exp_years" id="exp_years" size="1" maxlength="2" type="text" class="validateInteger"/> years
	          <input name="exp_months" id="exp_months" size="1" maxlength="2" type="text" class="validateInteger"/> months
	          <p class="formHint">Your experince. Put 0 if fresher.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="skills">Skills</label>
	          <textarea name="skills" id="skills" style="height:80px; width:360px;"></textarea>
	          <p class="formHint">Your skill set as per your experince and education.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="resume_headline">Resume Headline</label>
	          <input name="resume_headline" id="resume_headline" maxlength="160" type="text" class="textInput"/>
	          <p class="formHint">Headline of your resume.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="industry_id">Current Industry</label>
	           <select id="industry_id" name="industry_id" class="selectInput">
	           		<option value="0" selected="selected">Select Industry</option>
	           	<?php
	           		$industrySet = $this->industrySet;
	           		foreach ($industrySet as $key=>$industry){
	           			echo "<option value=$industry[industry_id]>";
	           			echo "$industry[industry_name]";
	           			echo "</option>";
	           			echo "\n";
	           		} 
	           	?>
	           </select>
	          <p class="formHint">Current industry your are working in.(if applicable)</p>
	        </div>
			
	        <div class="ctrlHolder">
	          <label for="fa_id">Functional Area</label>
	           <select id="fa_id" name="fa_id" class="selectInput">
	           		<option value="0" selected="selected">Select Industry</option>
	           	<?php
	           		$faSet = $this->faSet;
	           		foreach ($faSet as $key=>$fa){
	           			echo "<option value=$fa[fa_id]>";
	           			echo "$fa[fa_name]";
	           			echo "</option>";
	           			echo "\n";
	           		} 
	           	?>
 			   </select>
	          <p class="formHint">Current functional area.(if applicable)</p>
	        </div>        
        </fieldset>
        
        <div class="ctrlHolder noLabel">
          <ul>
            <li><label><input name="ug_check" id="ug_check" value="false" type="checkbox"/> Tick it, only if your are undergraduate.</label></li>
          </ul>
          <p class="formHint">Undergraduate check.</p>
        </div>
        
        <fieldset id="eduInfo">
	        <h3>Education Information</h3>
	        <div class="ctrlHolder">
	          <label for="course_type">Education Level</label>
	           <select id="course_type" name="course_type" class="selectInput required" onchange="javascript:getCourses();">
	           		<option value="" selected="selected">Select level</option>
	           		<option value="G">Graduate</option>
	         		<option value="PG" >Post Graduate</option>
	         		<option value="MP">Master of Philosphy</option>
	         		<option value="PD">Ph.d or Doctrate</option>
	           </select>
	          <p class="formHint">Your edcuation level which makes you eligible for job.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="course_id">Education Course</label>
	           <select id="course_id" name="course_id" class="selectInput required" disabled="disabled" onchange="javascript:getSpecializations();">
	           </select>
	          <p class="formHint">Your degree or course.</p>
	        </div>
	        
			<div class="ctrlHolder">
	          <label for="edu_spec_id">Education Specilization</label>
	           <select id="edu_spec_id" name="edu_spec_id" class="selectInput required" disabled="disabled">
	           </select>
	          <p class="formHint">Your specialization or course stream.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="edu_org_id">University or Institute</label>
	           <select id="edu_org_id" name="edu_org_id" class="selectInput required">
	           		<option value="" selected="selected">Select</option>
	           	<?php
	           		$eduOrgSet = $this->eduOrgSet;
	           		foreach ($eduOrgSet as $key=>$edu_org){
	           			echo "<option value=$edu_org[edu_org_id]>";
	           			echo $edu_org['edu_org_name'];
	           			echo "</option>";
	           			echo "\n";
	           		} 
	           	?>
	           </select>
	          <p class="formHint">University or institute applicable.</p>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label for="edu_style">Education Pattern</label>
	          	<input type="radio" name="edu_style" value="FT" checked="checked"/> Full Time &nbsp;
			  	<input type="radio" name="edu_style" value="PT" /> Part Time &nbsp;
			  	<input type="radio" name="edu_style" value="CC" /> Correspondance
			  <p class="formHint">Pattern of your course or degree.</p> 
	        </div>
	        	        
	        <div class="ctrlHolder">
	          <label for=""><em class="red">*</em>Year of passing</label>
	          	<input name="year_of_passing" id="year_of_passing" size="35" maxlength="4" type="text" class="validateInteger required"/>
	          <p class="formHint">Year of passing.</p>
	        </div>
        
        </fieldset>
        
        <div class="ctrlHolder">
	    	<input name="agree_check" id="agree_check" type="checkbox"  value="true" checked="checked" class="required"/>
	    	<span style="font-size: 12px">I have read and understood and agree to the <span class="simpleLinks"><a href="#">Terms and Conditions</a></span> governing the use of rpglobalconsultants.com.</span>
	    </div>
        <div class="buttonHolder">
        	<button type="submit" class="primaryAction">Submit</button>
        	<button type="reset" class="secondaryAction">Clear form</button>
      	</div>
        
	</form>
</div><!-- End #jobSeekerRgrnDiv -->
<div id="ajaxLoader">
	<img src="<?php echo $cdnUrl?>/images/ajax-loader.gif"> <span>Please Wait...</span>
</div>


<script type="text/javascript" src="<?php echo $cdnUrl?>/plugins/uni-form/js/uni-form.jquery.js"></script> 
<script type="text/javascript" src="<?php echo $cdnUrl?>/plugins/uni-form/js/uni-form-validation.jquery.js"></script>

<script type="text/javascript">
var urlJobSeekerRegister = "<?php $baseUrl?>/jobseeker/register/register";
var urlGetCourses = "<?php $baseUrl?>/jobseeker/register/getcourses";
var urlGetSpecializations = "<?php $baseUrl?>/jobseeker/register/getspecializations";
$(function(){
    $('form.uniForm').uniform({
      prevent_submit : true
    });
});

$("#ug_check").click(function(){
    if ($(this).is(':checked')) {
    	$(this).val(true);
    	$('#eduInfo :input').remove();
    	$('#eduInfo').fadeOut();
	} else {
		$(this).val(false);
		location.reload();
	}
    
});

function getCourses(){
	var val = $("#course_type").val();
	$.ajax({
	    url : urlGetCourses,
	    dataType : 'json',
	    type : "post",
	    data: {"course_type":val},
	    success: function(jCourses){
	    	var selectOptionString = '<option value ="0" selected="selected">Select Course</option>';
			$.each(jCourses, function (index, course) {
				selectOptionString += '<option value ="'+course.course_id+'">'+course.course_name+'</option>';
			});
			$('#course_id').removeAttr("disabled");
	        $('#course_id').html(selectOptionString);
	        
	   },
	   error: function(event) {
	        alert(event.responseText);
	   }
	});
	
}

function getSpecializations(){
	var val = $("#course_id").val();
	$.ajax({
	    url : urlGetSpecializations,
	    dataType : 'json',
	    type : "post",
	    data: {"course_id":val},
	    success: function(jSpecs){
	    	var selectOptionString = '<option value ="0" selected="selected">Select Specialization</option>';
			$.each(jSpecs, function (index, edu_spec) {
				selectOptionString += '<option value ="'+edu_spec.edu_spec_id+'">'+edu_spec.edu_spec_name+'</option>';
			});
			$('#edu_spec_id').removeAttr("disabled");
	        $('#edu_spec_id').html(selectOptionString);
	        
	   },
	   error: function(event) {
	        alert(event.responseText);
	   }
	});
	
}

function submit() {
	$("#ajaxLoader").css('display','block');
	var course = $('#course_id').val();
	var spec = $('#edu_spec_id').val();
	var org = $('#edu_org_id').val();
	if(course == 0){
		alert("Education course must be provided");
		$("#ajaxLoader").css('display','none'); 
		return false;
	}
	if(spec == 0){
		alert("Education specialization must be provided");
		$("#ajaxLoader").css('display','none'); 
		return false;
	}
	if(org == 0){
		alert("University/Institute must be provided");
		$("#ajaxLoader").css('display','none'); 
		return false;
	}
    $.ajax({
        url : urlJobSeekerRegister,
        type : "get",
        data : getValues(),
        success: function(jStatus){    
             alert('Server Message: '+ jStatus);
             $("#ajaxLoader").css('display','none'); 
             setTimeout(function(){
              	window.location.reload();
              	},1000);
        },
        error: function(response) {
        	alert('Server Error: '+response);
        	$("#ajaxLoader").css('display','none'); 
        	setTimeout(function(){
            	window.location.reload();
            	},1000);
        }
    });
}

function getValues() {
    var formData = {oper:'add'}; 
    $('form.uniForm :input')
    		.not('button,:input[value^="e.g."]')
    		.each(function(){ 
    			formData[this.name] = this.value; 
        });
    var edu_style = $('input:radio[name=edu_style]:checked').val();
    formData.edu_style = edu_style; 
	return formData;
}
</script>


